﻿using System;
using System.Data;
using System.Collections.Generic;
using NetDiskPRJ.Common;
using NetDiskPRJ.Model;
namespace NetDiskPRJ.BLL
{
	/// <summary>
	/// 用户组信息
	/// </summary>
	public partial class PrvGroup
	{
		public PrvGroup()
		{}
        /// <summary>
        /// 获取用户组定义列表
        /// <creator>wangl</creator>
        /// <date>2012-02-18</date>
        /// </summary>
        /// <returns></returns>
        public List<Model.PrvGroup> GetList()
        {
            NetDiskPRJ.DAL.PrvGroup prvGroupDAL=new NetDiskPRJ.DAL.PrvGroup();
            DataSet ds= prvGroupDAL.GetList("");
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获取用户组定义列表
        /// <creator>wangl</creator>
        /// <date>2012-02-18</date>
        /// </summary>
        /// <returns></returns>
        public List<Model.PrvGroup> GetModelList(string where)
        {
            NetDiskPRJ.DAL.PrvGroup prvGroupDAL=new NetDiskPRJ.DAL.PrvGroup();
            DataSet ds = prvGroupDAL.GetList(where);
            return DataTableToList(ds.Tables[0]);
        }
        
        /// <summary>
        /// 获得数据列表
        /// <creator>wangl</creator>
        /// <date>2012-02-18</date>
        /// </summary>
        private List<NetDiskPRJ.Model.PrvGroup> DataTableToList(DataTable dt)
        {
            NetDiskPRJ.DAL.PrvGroup prvGroupDAL = new NetDiskPRJ.DAL.PrvGroup();
            List<NetDiskPRJ.Model.PrvGroup> modelList = new List<NetDiskPRJ.Model.PrvGroup>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                NetDiskPRJ.Model.PrvGroup model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = prvGroupDAL.DataRowToModel(dt.Rows[n]);
                    if (model != null)
                    {
                        modelList.Add(model);
                    }
                }
            }
            return modelList;
        }
        /// <summary>
        /// 是否存在该组ID记录
        /// <creator>wangl</creator>
        /// <date>2013-02-18</date>
        /// </summary>
        public bool ExistsGrp(string groupNo)
        {
            NetDiskPRJ.DAL.PrvGroup prvGroupDAL = new NetDiskPRJ.DAL.PrvGroup();
            return prvGroupDAL.ExistsGrp(groupNo);
        }
         /// <summary>
        /// 增加一条数据
        /// <creator>wangl</creator>
        /// <date>2013-02-18</date>
        /// </summary>
        public bool Add(Model.PrvGroup model)
        {
            NetDiskPRJ.DAL.PrvGroup prvGroupDAL = new NetDiskPRJ.DAL.PrvGroup();
            return prvGroupDAL.Add(model);
        }
        /// <summary>
        /// 更新一条数据
        /// <creator>wangl</creator>
        /// <date>2013-02-18</date>
        /// </summary>
        public bool Update(Model.PrvGroup model)
        {
            NetDiskPRJ.DAL.PrvGroup prvGroupDAL = new NetDiskPRJ.DAL.PrvGroup();
            return prvGroupDAL.Update(model);
        }
         /// <summary>
        /// 删除一条数据
        /// <creator>wangl</creator>
        /// <date>2013-02-18</date>
        /// </summary>
        public bool Delete(string groupNo)
        {
            NetDiskPRJ.DAL.PrvGroup prvGroupDAL = new NetDiskPRJ.DAL.PrvGroup();
            return prvGroupDAL.Delete(groupNo);
        }
	}
}

